package com.example.demo.controlller;

import com.example.demo.pojo.Doc;
import com.example.demo.pojo.PageBean;
import com.example.demo.pojo.Result;
import com.example.demo.service.Docservice;
import com.example.demo.service.Impl.Docserviceimpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/doc")
public class Doccontroller {
    @Autowired
    Docservice docservice;

    /**
     * 医生页面查询所有数据
     *
     * @return
     */
    @RequestMapping("/queryAll")
    public Result queryAll() {
        List<Doc> Dlist = docservice.queryAll();
        return Result.success(Dlist);

    }

    @RequestMapping("/queryName")
    public Result queryName(String name) {
        List<Doc> list = docservice.queryName(name);
        return Result.success(list);
    }

    @RequestMapping("/delete")
    public Result delete(String docid) {
        docservice.delete(docid);
        return Result.success();
    }

    @RequestMapping("/add")
    public Result insert(@RequestBody Doc doc) {
        docservice.insert(doc);
        return Result.success();
    }

    @RequestMapping("/update")
    public Result update(@RequestBody Doc doc) {
        docservice.update(doc);
        return Result.success();
    }

    @RequestMapping("/page1")
    public Result page(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer pageSize) {
        PageBean pageBean = docservice.page(page, pageSize);
        return Result.success(pageBean);
    }


}
